<?php


class material_ctl_admin_material_test extends desktop_controller
{

	public function test(){
		$str='[
{"存货编码":"BH3130L0301","weight":"13800"},
{"存货编码":"BH3136L0302","weight":"930"},
{"存货编码":"BL3001G9401","weight":"7900"},
{"存货编码":"BL3002G3901","weight":"4320"},
{"存货编码":"BR3100T1801","weight":"1860"},
{"存货编码":"BR3100U1801","weight":"2040"},
{"存货编码":"BR3100U1804","weight":"1940"},
{"存货编码":"BR3100U1806","weight":"1940"},
{"存货编码":"BR3110T1801","weight":"2210"},
{"存货编码":"BR3136S0305","weight":"540"},
{"存货编码":"BR3136S0604","weight":"1100"},
{"存货编码":"BR3136S0606","weight":"1100"},
{"存货编码":"BR3136S0607","weight":"1100"},
{"存货编码":"BR3136S1201","weight":"2080"},
{"存货编码":"BR3136S1801","weight":"3120"},
{"存货编码":"BR3136S1802","weight":"3100"},
{"存货编码":"BR3136S1803","weight":"3120"},
{"存货编码":"BR3136S2401","weight":"4080"},
{"存货编码":"BR3136S2403","weight":"4240"},
{"存货编码":"BR3136S2406","weight":"4240"},
{"存货编码":"BR3150L0305","weight":"780"},
{"存货编码":"BR3150M0304","weight":"640"},
{"存货编码":"BR3150M2401","weight":"5250"},
{"存货编码":"BS3008G1801","weight":"351.66"},
{"存货编码":"BS3008G5401","weight":"1120"},
{"存货编码":"BS4008G1002","weight":"240"},
{"存货编码":"BS4008G1004","weight":"1000"},
{"存货编码":"BS4008G12001","weight":"3100"},
{"存货编码":"BS4008G12002","weight":"3000"},
{"存货编码":"BS4008G3001","weight":"750"},
{"存货编码":"BS4008G6001","weight":"1540"},
{"存货编码":"BS4008G6002","weight":"1540"},
{"存货编码":"BX4140G1002","weight":"1510"},
{"存货编码":"BX4140G2001","weight":"3220"},
{"存货编码":"BX4140G2702","weight":"4340"},
{"存货编码":"BX4180G2001","weight":"4140"},
{"存货编码":"BX4180G2401","weight":"5150"},
{"存货编码":"BX4180G3001","weight":"6200"},
{"存货编码":"BY4080G1201","weight":"7820"},
{"存货编码":"BY4080G1202","weight":"980"},
{"存货编码":"BY4080G1203","weight":"1080"},
{"存货编码":"BY4080G2401","weight":"2080"},
{"存货编码":"BY4080G2402","weight":"2100"},
{"存货编码":"BY4120G1401","weight":"1697.5"},
{"存货编码":"CR3136S2402","weight":"3880"},
{"存货编码":"CR3150L1801","weight":"4780"},
{"存货编码":"CX3200G2001","weight":"4580"},
{"存货编码":"DR3110T1001","weight":"9840"},
{"存货编码":"DR3110T2402","weight":"2560"},
{"存货编码":"DR3120T0804","weight":"974"},
{"存货编码":"DR3120T2401","weight":"2940"},
{"存货编码":"DR3136S0604","weight":"894"},
{"存货编码":"DR3136S1801","weight":"2820"},
{"存货编码":"DR3136S2401","weight":"3700"},
{"存货编码":"DS3008G1002","weight":"189.58"},
{"存货编码":"DS3008G3002","weight":"560"},
{"存货编码":"DS3008G6001","weight":"1140"},
{"存货编码":"DX3140G2701","weight":"4400"},
{"存货编码":"DY3080G4001","weight":"3440"},
{"存货编码":"ER3100U0501","weight":"600"},
{"存货编码":"ER3100U1801","weight":"2000"},
{"存货编码":"ER3130S0601","weight":"988"},
{"存货编码":"ER3130S1201","weight":"2020"},
{"存货编码":"ER3130S1601","weight":"2680"},
{"存货编码":"ER3130S1801","weight":"3100"},
{"存货编码":"ER3130S2401","weight":"3840"},
{"存货编码":"ER3150S0601","weight":"1127"},
{"存货编码":"ER3150S1201","weight":"2320"},
{"存货编码":"ER3150S1202","weight":"2320"},
{"存货编码":"ER3150S1601","weight":"3060"},
{"存货编码":"ER3150S1801","weight":"3440"},
{"存货编码":"ER3150S1802","weight":"3500"},
{"存货编码":"ER3150S2401","weight":"4450"},
{"存货编码":"ES3010G1001","weight":"240"},
{"存货编码":"ES3010G1003","weight":"243"},
{"存货编码":"ES3010G3001","weight":"760"},
{"存货编码":"ES3010G6001","weight":"1500"},
{"存货编码":"EX4140G1001","weight":"1490"},
{"存货编码":"EX4140G2701","weight":"4400"},
{"存货编码":"EX4140G2702","weight":"4380"},
{"存货编码":"WX0LYR3130U2401","weight":"3500"},
{"存货编码":"WX0LYS4008G10001","weight":"2660"},
{"存货编码":"WX0LYX4140G2701","weight":"4760"},
{"存货编码":"X0LLR000101","weight":"4100"},
{"存货编码":"X0LYR3130U0601","weight":"3460"},
{"存货编码":"X0PYR3130S2401","weight":"3960"},
{"存货编码":"X0PYS4008G6001","weight":"1540"},
{"存货编码":"X0PYX4140G2701","weight":"4440"},
{"存货编码":"X1BBR3136S2004","weight":"3540"},
{"存货编码":"X1BBS4008G1002","weight":"2620"},
{"存货编码":"X1JLM3025G6401","weight":"3160"},
{"存货编码":"X1JLR3130M0402","weight":"3830"},
{"存货编码":"X1JLR3136M0402","weight":"4060"},
{"存货编码":"X1JLX4140G2701","weight":"4480"},
{"存货编码":"X1JLX4180G2401","weight":"4940"},
{"存货编码":"X1WSR3130U0601","weight":"3740"},
{"存货编码":"X1WSX4140G2701","weight":"4440"},
{"存货编码":"X1XXR3150S1801","weight":"3480"},
{"存货编码":"X2ZZR3130M0401","weight":"3860"},
{"存货编码":"X2ZZX4150G0901","weight":"4760"},
{"存货编码":"X3ZZR3136S0301","weight":"10540"},
{"存货编码":"X3ZZR3136S1601","weight":"2820"},
{"存货编码":"X3ZZR3136S1602","weight":"2820"},
{"存货编码":"X3ZZR3136S2401","weight":"4180"},
{"存货编码":"X3ZZR3136S2402","weight":"4180"},
{"存货编码":"X3ZZS4008G1001","weight":"1560"},
{"存货编码":"X3ZZS4008G1002","weight":"3080"},
{"存货编码":"X3ZZS4008G1003","weight":"11680"},
{"存货编码":"X3ZZS4008G12001","weight":"3020"},
{"存货编码":"X3ZZX4140G1001","weight":"9060"},
{"存货编码":"X3ZZX4140G2701","weight":"4020"},
{"存货编码":"X4JZR3130S0302","weight":"4280"},
{"存货编码":"X4JZS3010G0601","weight":"3800"},
{"存货编码":"X4JZS3010G0602","weight":"3800"}
]';
		$strNew = json_decode($str, 1);
        $materialObj = app::get('material')->model('basic_material');
        // $salesMaterialObj = app::get('material')->model('sales_material');
        foreach ($strNew as $key => $val) {

            if ($val['存货编码'] != '') {
                $iteminfo['material'] = $materialObj->dump(array('material_bn' => $val['存货编码']), 'material_bn,bm_id,material_name');
                if (!empty($iteminfo['material'])) {
                    $filter['bm_id'] = $iteminfo['material']['bm_id'];
                    $update['weight'] = $val['weight'];
                    $rs = app::get('material')->model('basic_material_ext')->update($update, $filter);
                    error_log(print_r('/' . $val['存货编码'] . '/' . $rs, 1) . PHP_EOL, 3, DATA_DIR . "/yes_weight.log");
                } else {
                    error_log(print_r('/' . $val['存货编码'], 1) . PHP_EOL, 3, DATA_DIR . "/no_weight.log");
                }
            }

        }

	}

}